<template>
  <div class="Counterequipment-section">
    <Title title="设备栏" />
    <div class="Counterequipment-data">
      <div class="data-item" v-for="item in DeviceList" :key="item.id" @click="jump(item)">
        <div class="item-content">
          <div class="item-left">
            <img
              :src="`/img/${
                item.deviceType == 4
                  ? 'quanxiang'
                  : item.deviceType == 5
                  ? 'dingxiang'
                  : item.deviceType == 7
                  ? 'cexiang'
                  : item.deviceType == 8
                  ? 'leida'
                  : item.deviceType == 9
                  ? 'jiema'
                  : item.deviceType == 10
                  ? 'ADS-B'
                  : ''
              }.png`"
              alt="" />
            <span
              class="text"
              :title="item.deviceTypeName.length > 10 ? item.deviceTypeName : ''"
              >{{ item.deviceType == 9?'无线电解码侦测':item.deviceTypeName }}</span
            >
          </div>
          <img src="/img/normal.png" alt="链路正常" v-if="item.workStatus == 1" />
          <img src="/img/abnormal.png" alt="链路异常" v-else />
        </div>
        <div class="item-line"></div>
      </div>
    </div>
  </div>
</template>

<script setup>
  import { ref, onMounted } from 'vue'
  import Title from '@/components/home/title.vue'
  import { getDeviceList } from '@/api/home.js'

  const emits = defineEmits(['Jumpdevicedialog'])

  let DeviceList = ref([])
  // let CountermeasuresList = ref([])

  const getDeviceListData = () => {
    getDeviceList().then((res) => {
      DeviceList.value = res.data
      // CountermeasuresList.value = DeviceList.value.filter((item) => {
      //   return item.type == 2
      // })
    })
  }

  const jump = (item) => {
    emits('Jumpdevicedialog', item)
  }

  defineExpose({ DeviceList })

  onMounted(() => {
    getDeviceListData()
  })
</script>

<style scoped lang="scss">
  .Counterequipment-section {
    position: relative;
    width: 100%;
    height: 25%;
    .Counterequipment-data {
      height: 100%;
      overflow-y: scroll;
      .data-item {
        cursor: pointer;
        padding-left: 10%;
        .item-content {
          display: flex;
          justify-content: space-between;
          align-items: center;
          height: 46px;
          .item-left {
            display: flex;
            align-items: center;
          }
          .text {
            width: 200px;
            color: #c3efff;
            font-size: 14px;
            padding-left: 20px;
            white-space: nowrap; /* 防止文本换行 */
            overflow: hidden; /* 超出部分隐藏 */
            text-overflow: ellipsis; /* 使用省略号隐藏 */
          }
        }
        .item-line {
          height: 1px;
          background-color: #2d4558;
          margin: 0 auto;
          transform: translateX(4px);
        }
      }
    }
    /* 去除滚动条 */
    .Counterequipment-data::-webkit-scrollbar {
      display: none;
    }
  }
</style>
